package cn.itrip.auth.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.itrip.auth.service.TestService;
import cn.itrip.beans.dto.Dto;
import cn.itrip.beans.pojo.ItripUser;
import cn.itrip.common.DtoUtil;
import cn.itrip.common.ErrorCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

@RestController
@RequestMapping(value = "/api/user")
public class TestController {
	@Resource
	private TestService testService;
	
	
	@RequestMapping(value = "/get/{id}")
	@ApiOperation(value = "根据id查询用户信息",httpMethod = "GET",protocols = "HTTP",produces = "application/json",response = Dto.class,notes = "成功：success='true'<br />失败：success='false'")
	public Dto<ItripUser> get(@ApiParam(required = false,name="id",value = "用户Id") @PathVariable(value = "id")Long id) {
		Dto<ItripUser> dto = null;
		try {
			ItripUser user = testService.getUser(id);
			dto = DtoUtil.returnDataSuccess(user);
		} catch (Exception e) {
			e.printStackTrace();
			dto = DtoUtil.returnFail("获取用户信息失败", ErrorCode.AUTH_UNKNOWN);
		}
		return dto;
	}
	

}
